// shared variable
//   can be exchanged between a thread and the calling thread
//   created as shared and passed to the thread as such, too
//   the underlying `struct` contains a hidden mutex: `rlock` for read-only and `lock` for read/write

struct St {
mut:
	x int // data to be shared
}

fn (shared b St) g(x int) {
	lock b {
		b.x = x
	}
}

fn main() {
	shared a := St{
		x: 10
	}
	go a.g(20)
	rlock a {
		println(a.x)
	}
}
